﻿namespace PugLib.UI
{
	using System;
	using System.Threading.Tasks;

	public class TaskForm : PugForm
	{
		private readonly Lazy<TaskScheduler> _uiScheduler = new Lazy<TaskScheduler>(TaskScheduler.FromCurrentSynchronizationContext);

		/// <summary>
		/// Task scheduler representing the thread on which this form was created. 
		/// Used for callbacks to the UI thread so background tasks don't need to invoke manually.
		/// </summary>
		public TaskScheduler UIScheduler
		{
			get { return _uiScheduler.Value; }
		}

		/// <summary>
		/// Returns false. All exceptions will bubble-up.
		/// </summary>
		public static Func<Exception, Boolean> HandleZeroExceptions
		{
			get { return ex => false; }
		}
	}
}